Page({
    data: {
        text: '3.1415',
        copy: '',
    },
    //打电话
    makePhoneCall() {
        my.makePhoneCall({ number: '95555' });
    },
    //震动
    vibrate() {
        my.vibrate({
            success: () => {
                my.alert({ title: '震动起来了'});
            }
        });
    },
    //监听摇一摇
    watchShake() {
        my.watchShake({
        success: function() {
            console.log('动起来了')
            my.alert({ title:'动起来了 o.o'});
        }
        });
    },
    //设置剪切板信息
    handleCopy() {
        my.setClipboard({
            text: this.data.text,
        });
    },
    //获取剪切板信息
    handlePaste() {
        my.getClipboard({
            success: ({ text }) => {
                this.setData({ copy: text });
                my.alert({title:this.data.copy})
            },
        });
    },
    //获取网络状态
    getNetworkType() {
        my.getNetworkType({
        success: (res) => {
            this.setData({
                hasNetworkType: true,
                networkType: res.networkType
            })
            my.alert({title:this.data.networkType})
        }
        })
    },
    //清空网络状态
    clear() {
        this.setData({
            hasNetworkType: false,
            networkType: ''//清空网络状态
        })
        my.alert({title:"清空网络状态,请重新获取"})
    },
    //监听网络状态
    watchNetType(){
        my.onNetworkStatusChange(function(res){
            console.log(JSON.stringify(res))
            my.alert({title:JSON.stringify(res)})
        })
    },
    //取消监听网络状态
    offWatchNetType(){
        my.offNetworkStatusChange()
    },
    // 获取系统信息
    getSystemInfoPage() {
        //getSystemInfoSync()同步获取
        //异步获取
        my.getSystemInfo({
            success: (res) => {
                this.setData({
                    systemInfo: res
                })
                my.alert({title:JSON.stringify(res)})
            }
        })
    },
});